import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:qilo/core/utils/app_utils.dart';

class AncientTermsWhisper extends StatelessWidget {
  const AncientTermsWhisper({super.key});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 40.w),
      child: RichText(
        textAlign: TextAlign.center,
        text: TextSpan(
          style: TextStyle(
            fontSize: 12.sp,
            color: Colors.white.withValues(alpha: 0.8),
            height: 1.4,
          ),
          children: [
            const TextSpan(text: 'By continuing, you agree to our '),
            TextSpan(
              text: 'Terms of Service',
              style: TextStyle(
                decoration: TextDecoration.underline,
                fontWeight: FontWeight.w500,
                color: Colors.white,
              ),
              recognizer:
                  TapGestureRecognizer()
                    ..onTap = () => _openTermsOfService(context),
            ),
            const TextSpan(text: ' and '),
            TextSpan(
              text: 'EULA',
              style: TextStyle(
                decoration: TextDecoration.underline,
                fontWeight: FontWeight.w500,
                color: Colors.white,
              ),
              recognizer:
                  TapGestureRecognizer()..onTap = () => _openEULA(context),
            ),
          ],
        ),
      ),
    );
  }

  void _openTermsOfService(BuildContext context) {
    AppUtils.openUrl(
      'https://www.freeprivacypolicy.com/live/d17327ba-4512-48f5-b743-6215587159ec',
    );
  }

  void _openEULA(BuildContext context) {
    AppUtils.openUrl(
      'https://www.freeprivacypolicy.com/live/82e54f5c-a3a3-4bc8-a08a-0da176425cf4',
    );
  }
}
